﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Project.Ycm20250401.Service._20250407
{
    public class OrderService(
     PriceStrategyFactory strategyFactory
     )
    {
        public async Task SubmitOrderAsync(Order order, Activity activity)
        {
            // 应用价格策略
            var strategy = strategyFactory.GetStrategy(activity.Type);
            order.FinalPrice = strategy.CalculatePrice(order.OriginalPrice, activity);

            // 验证及持久化
            ValidateOrder(order);
           // await orderRepo.SaveAsync(order);

           // Console.WriteLine($"Order submitted. Final price: {order.FinalPrice}");
        }

        private void ValidateOrder(Order order) { /* 验证逻辑 */ }
    }

    public class Order
    {
        public decimal OriginalPrice { get; set; }
        public decimal FinalPrice { get; set; }

        public Order(decimal OriginalPrice) { this.OriginalPrice = OriginalPrice; }
    }

}
